package com.cms.admin.service.privilege.impl;

import java.util.List;





import com.cms.admin.mapper.UserListMapper;

import com.cms.admin.model.PageBean;
import com.cms.admin.model.UserList;
import com.cms.admin.model.UserListExt;
import com.cms.admin.service.privilege.UserListService;

/**
 * @author bobo
 *
 */
 
public class UserListServiceImpl implements UserListService {

	
	private UserListMapper userListMapper;


	@Override
	public void insertUser(UserList user) {
		// TODO Auto-generated method stub
		int result=userListMapper.insertUser(user);
		System.out.println("新增用户结果:"+result);
	}

	public UserListMapper getUserListMapper() {
		return userListMapper;
	}

	public void setUserListMapper(UserListMapper userListMapper) {
		this.userListMapper = userListMapper;
	}
	@Override
	public UserList getById(long id) {
		return userListMapper.getById(id);
	}

	@Override
	public 	List<UserList> getAllUser(PageBean page ,UserListExt search){
		int count=getRowCount(search);
		page.setAllRow(count);
		search.setOffset(page.getOffset());
		search.setPageSize(page.getPageSize());

		// TODO Auto-generated method stub
		return userListMapper.getUserByConditionWithLimit(search);
	}
	
	
	@Override
	public int getRowCount(UserListExt search) {
		// TODO Auto-generated method stub
		return userListMapper.countByCondition(search);
	}
	
	@Override
	public void deleteUser(String id) {
		userListMapper.deleteUser(id);
	}
	 
	@Override
	public UserList getByName(String userName) {
		return userListMapper.getByName(userName);
	}

	@Override
	public UserList getByNo(String userNo) {
		return userListMapper.getUserByUserNo(userNo);
	}

	@Override
	public void updateUser(UserList user) {
		userListMapper.updateUser(user);
	}

	@Override
	public int updateUserSelective(UserList record) {
		return userListMapper.updateByUserIdSelective(record);
	}

	@Override
	public void updateSelfPassword(UserList user) {
		userListMapper.updateSelfPassword(user);
		
	}
	@Override
	public void updateSelfInfoById(UserList user) {
		userListMapper.updateByUserIdSelective(user);
	}
	@Override
	public void resetUserPassword(UserList user) {
		userListMapper.resetUserPassword(user);
	}
 
}
